package com.wang.sqlsession;


import org.apache.commons.lang3.StringUtils;

/**
 * Created by wangq on 2021/7/4.
 *
 * sql语句的操作类型
 */
public enum SqlCommandType {
    INSERT(0, "新增"),
    UPDATE(1, "修改"),
    DELETE(2, "删除"),
    SELECT(3, "查询"),
    UNKNOWN(4, "未知");

    int value;
    String content;

    SqlCommandType(int value, String content) {
        this.value = value;
        this.content = content;
    }

    public static SqlCommandType convertToType(String type) {
        if (StringUtils.isNotEmpty(type)) {
            for (SqlCommandType sqlCommandType : SqlCommandType.values()) {
                if (StringUtils.equals(sqlCommandType.name().toUpperCase(), type.toUpperCase())) {
                    return sqlCommandType;
                }
            }
        }
        return UNKNOWN;
    }
}
